<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../../css/orderDetails.css" />
		<script src="../../js/Width.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body style="background-color: #F2F2F2;">
		<div id="staff" >
			<header class="mui-bar mui-bar-nav">
				<a style="color: #fff;" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
				<h1 class="mui-title" style="color: #fff;">选择指派人</h1>
				<div class="save" @click="saveClick" >确定</div>
			</header>
			</header>
			<div class="staff-content">
				<!--<div class="staff-list">
					<div class="staff-list-item" v-for="item in list" @click="staffItemClick(item)">
						<div class="staff-wapper" :style="item.empID===id?'transform: rotateY(180deg);':''">
							<div class="card item-front">
								<img :src="item.empIcon" />
								<div class="item-name">
									<span>{{item.empName}}</span>
								</div>
							</div>
							<div class="card item-back">
								<img class="item-br" :src="item.empIcon" />
								<img class="item-icon" src="../../images/saff-img.png" alt="" />
							</div>
						</div>
					</div>
				</div>-->
				
				<div class="staff-list">
					<div class="list-item" v-for="item in list" @click="staffItemClick(item)">
						<div class="item-imgUrl"><img :src="item.empIcon||'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1529382604731&di=6e0415e1f41804a3420d09112f0b9f67&imgtype=0&src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F01%2F48%2F88%2F2757444507812f6.jpg'" /></div>
						<div class="item-name">{{item.empName}}</div>
						<div v-if="item.empID==id"  class="item-icon">
							<img src="../../images/saff-img.png"/>
						</div>
					</div>
				</div>
				
			</div>
		</div>

		<script src="../../js/mui.min.js"></script>
		<script src="../../js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/util.js" type="text/javascript" charset="utf-8"></script>
		<script src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>
		<script type="text/javascript">
			mui.init()
			
			mui.plusReady(function() {
				FastClick.attach(document.body);
				
				GetEmployeeList()
			})
			var staff = new Vue({
				el: '#staff',
				data: {
					id:'',
					name:'',
					list: []
				},
				methods: {
					staffItemClick:function(item){
						console.log(item)
						this.id = item.empID
						this.name = item.empName
					},
					saveClick :function(){
						if(this.id==''){
							mui.toast('请选择！')
							return
						}
						var that = this
						plus.nativeUI.confirm("您确定要指派给？", function(e) {
							if(e.index == 0) {
								AssignTask(that.id)
							}
						});
						
					}
				}
			})
			
			
			function  GetEmployeeList (){
				mui.post(httpUrl.testUrl+'/api/TaskAssignments/GetEmployeeList',{
					empID:plus.storage.getItem("empID")
				},function(res){
					console.log(res.code)
					
					if(res.code===1001){
						staff.list = res.data
					}else{
						mui.toast('请求错误')
					}
					
				})
			}

            function  AssignTask (id){
            	var data = plus.webview.currentWebview();
				mui.post(httpUrl.testUrl+'/api/TaskAssignments/AssignTask',{
					userID:plus.storage.getItem("userID"),
					rouID:data.rouID,
					rouType:data.rouType,
					gtaID: data.gtaID,
					empID:id
				},function(res){
					console.log(res.code)
					if(res.code===1001){
						mui.toast('指派成功！')
						setTimeout(function(){
							mui.back()
							var ws=plus.webview.currentWebview().opener();
	                        plus.webview.close(ws);
						},1000)
					}else{
						mui.toast('请求错误')
					}
					
				})
			} 				  

			
		</script>
	</body>

</html>